package testMore;

import java.util.*;

public class Test101 {
    public static void main(String[] args) {
        String ss = "1,1,1,,1";
        ss = ss.replaceAll("[,]+",",");
        System.out.println(ss);
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int num = scanner.nextInt();
            List<Integer> list = new ArrayList<>();
            while (num > 0) {
                list.add(scanner.nextInt());
                num--;
            }
            int asc = scanner.nextInt();
            if (asc==0){
                Collections.sort(list);
            }else if (asc == 1){
                list.sort(Comparator.reverseOrder());
            }

            list.forEach(integer -> System.out.print(integer+" "));
            System.out.println("");
        }
    }
}
